package com.tongguan.paypos.common;

import com.tongguan.paypos.entity.SettleTotal;
import com.tongguan.paypos.entity.Total;
import com.tongguan.paypos.utils.Arith;
import com.tongguan.paypos.utils.L;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Joylive on 2016/12/20 .
 */

public class CountTotal {

//    // 统计笔数
//    private int num = 0;
//    private int fnum = 0;
//    // 总计元
//    private double money = 0.0d;
//    private double fmoney = 0.0d;
//    // 支付方式笔数
//    private int wxNum = 0;
//    private int zfbNum = 0;
//    private int yNum = 0;
//    private int cashNum = 0;
//    private int hycNum = 0;
//    private int qqNum = 0;
//    private int posNum = 0;
//    private int jfNum = 0;
//    private int dkNum = 0;
//    private int wkNum = 0;
//    // 支付金额
//    private double wxMoney = 0.0d;
//    private double zfbMoney = 0.0d;
//    private double yMoney = 0.0d;
//    private double cashMoney = 0.0d;
//    private double hycMoney = 0.0d;
//    private double qqMoney = 0.0d;
//    private double posMoney = 0.0d;
//    private double jfMoney = 0.0d;
//    private double dkMoney = 0.0d;
//    private double wkMoney = 0.0d;
//    // 撤销笔数
//    private int fwxNum = 0;
//    private int fzfbNum = 0;
//    private int fyNum = 0;
//    private int fhckNum = 0;
//    private int fqqNum = 0;
//    private int fposNum = 0;
//    private int fwkNum = 0;
//    // 撤销金额
//    private double fwxMoney = 0.0d;
//    private double fzfbMoney = 0.0d;
//    private double fyMoney = 0.0d;
//    private double fhycMoney = 0.0d;
//    private double fqqMoney = 0.0d;
//    private double fposMoney = 0.0d;
//    private double fwkMoney = 0.0d;

    //统计总笔数
    public static List<Total> getCountTotal(List<SettleTotal> mSettleTotals) {
        List<Total> totals = new ArrayList<>();
        int totalNum = 0;
        String totalMoney = "0.0";
        for (SettleTotal mSettleTotal : mSettleTotals) {
            Total total = null;
            if ("0".equals(mSettleTotal.getState())) {
                totalNum = totalNum + mSettleTotal.getTotalCount();
                totalMoney = Arith.add(totalMoney,mSettleTotal.getTotalMoney());//支持千万级别
                String channelId = mSettleTotal.getChannelId();
                if ("WX".equals(channelId)){
                    total = new Total("wx",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("ZFB".equals(channelId)){
                    total = new Total("zfb",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("YZF".equals(channelId)){
                    total = new Total("yzf",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("XJ".equals(channelId)){
                    total = new Total("xj",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("HYC".equals(channelId)){
                    total = new Total("hyc",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("QQ".equals(channelId)){
                    total = new Total("qq",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("YL".equals(channelId)){
                    total = new Total("pos",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("JF".equals(channelId)){
                    total = new Total("jf",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("DK".equals(channelId)){
                    total = new Total("dk",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("XL".equals(channelId)){
                    total = new Total("xl",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }else if ("YLSM".equals(channelId)){
                    total = new Total("ylsm",mSettleTotal.getTotalCount(),mSettleTotal.getTotalMoney(),0,"");
                }
                if (total!=null)
                totals.add(total);
            }
        }
        totals.add(new Total("total", totalNum,totalMoney, 0,""));
        return totals;
    }

}
